package poker;
import javax.swing.*;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class CardGui extends JButton {
  //boolean hide;
  final ImageIcon icon, icon2, back;
  private static final long serialVersionUID = 1L;
  
  public CardGui(int suit, int rank) {
    //final String nameoffile = "/images/("+suit+","+rank+").png";
	icon = new ImageIcon(TableGui.class.getResource("/images/("+suit+","+rank+").png"));
	icon2 = new ImageIcon(TableGui.class.getResource("/images/("+suit+","+rank+") - Kopia.png"));
	back = new ImageIcon(TableGui.class.getResource("/images/back.png"));
	setIcon(back);
	addActionListener(new ActionListener() {
	  public void actionPerformed(ActionEvent e) {
	    if (getIcon() == icon2) { setIcon(icon); /* setEnabled(false); */ }
	    else if(getIcon() == icon){ setIcon(icon2); /*setOpaque(true); */ }
	    else { setIcon(back); /*setOpaque(true); setEnabled(false); setIcon(new ImageIcon(TableGui.class.getResource("/images/back.png"))); */ }
	  }
    });
  }
  
  public boolean hideornot(){
    if (getIcon() == icon2)	{ return true; }
    return false;
  }
  
  public void showCard(boolean show){
    if (show) { setIcon(icon); }
    else setIcon(back);
  }
  
  public void disable(){ setEnabled(false); }

}
